import React from 'react'
import { useSearchParams } from 'react-router-dom'

// 它是Message的子路由组件
export default function MessageDetail() {
  // 读取query/search参数
  const [search, setSearch] = useSearchParams()
  const id2 = search.get('id2')
  const title2 = search.get('title2')
  const content2 = search.get('content2')


  return (
    <>
      <ul>
        <li>ID: {id2}</li>
        <li>TITLE: {title2}</li>
        <li>CONTENT: {content2}</li>
      </ul>
      {/* 很少用setSearch  纯了解 */}
      <button onClick={() => setSearch('id2=1&title2=2&content2=3')}>使用setSearch</button>
    </>
  )
}
